/**
 * Promise的类方法 - allSettled
 * 是一个语法糖
 */
//console.log(Object.getOwnPropertyDescriptors(Promise))
const p1 = new Promise((resolve, reject) => {
  setTimeout(() => {
    resolve('1111')
  }, 1000)
})
const p2 = new Promise((resolve, reject) => {
  setTimeout(() => {
    resolve('2222')
  }, 2000)
})
const p3 = new Promise((resolve, reject) => {
  setTimeout(() => {
    // resolve('3333')
    reject('p3 reject error')
  }, 500)
})
//只要有一个Promise变为fulfilled状态那么就结束
//如果最先的是rejected，则会进入catch
Promise.race([p1, p2, p3])
  .then((res) => {
    console.log(res)
  })
  .catch((err) => {
    console.log(err)
  })
